package sangpil.net
{
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.URLRequest;
	
	import sangpil.events.SimpleLoaderEvent;

	[Event(name = "completed",type = "sangpil.events.SimpleLoaderEvent")]
	public class SimpleLoader extends EventDispatcher
	{
		private var loader:Loader;
		public function SimpleLoader()
		{
			super();
		}
		
		public function load(url:String):void
		{
			this.loader = new Loader();
			this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			this.loader.load(new URLRequest(url));
		}
		
		private function onComplete(e:Event):void
		{
			var loadInfo:LoaderInfo = e.target as LoaderInfo;
			//trace(loadInfo.content);
			this.dispatchEvent(new SimpleLoaderEvent(loadInfo.content, SimpleLoaderEvent.COMPLETED));
		}
		
	}
}